/* eslint-disable max-statements */ import type { ParsedUrlQuery } from 'querystring'; import type { GetStaticPaths, GetStaticProps } from 'next'; import Head from 'next/head'; import { useRouter } from 'next/router'; import Script from 'next/script'; import { useIntl } from 'react-intl'; import { getLayout, Heading, LinksWidget, PostsList, Page, PageHeader, PageSidebar, TocWidget, PageBody, } from '../../components'; import { getAllThematicsSlugs, getThematicBySlug, getThematicsPreview, getTotalThematics, } from '../../services/graphql'; import styles from '../../styles/pages/blog.module.scss'; import type { NextPageWithLayout, PageLink, Thematic } from '../../types'; import { CONFIG } from '../../utils/config'; import { ROUTES } from '../../utils/constants'; import { getLinksItemData, getPageLinkFromRawData, getPostsWithUrl, getSchemaJson, getSinglePageSchema, getWebPageSchema, } from '../../utils/helpers'; import { loadTranslation, type Messages } from '../../utils/helpers/server'; import { useBreadcrumb, useHeadingsTree } from '../../utils/hooks'; export type ThematicPageProps = { currentThematic: Thematic; thematics: PageLink[]; translation: Messages; }; const ThematicPage: NextPageWithLayout = ({ currentThematic, thematics, }) => { const { content, intro, meta, slug, title } = currentThematic; const { articles, dates, seo, topics } = meta; const intl = useIntl(); const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, url: `${ROUTES.THEMATICS.INDEX}/${slug}`, }); const { ref, tree } = useHeadingsTree({ fromLevel: 2 }); const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ description: seo.description, locale: CONFIG.locales.defaultLocale, slug: asPath, title: seo.title, updateDate: dates.update, }); const articleSchema = getSinglePageSchema({ dates, description: intro, id: 'thematic', kind: 'page', locale: CONFIG.locales.defaultLocale, slug: asPath, title, }); const schemaJsonLd = getSchemaJson([webpageSchema, articleSchema]); const thematicsListTitle = intl.formatMessage({ defaultMessage: 'Other thematics', description: 'ThematicPage: other thematics list widget title', id: 'KVSWGP', }); const topicsListTitle = intl.formatMessage({ defaultMessage: 'Related topics', description: 'ThematicPage: related topics list widget title', id: '/42Z0z', }); const pageUrl = `${CONFIG.url}${asPath}`; const tocTitle = intl.formatMessage({ defaultMessage: 'Table of Contents', description: 'PageLayout: table of contents title', id: 'eys2uX', }); return ( {seo.title} {/*eslint-disable-next-line react/jsx-no-literals -- Name allowed */} {/*eslint-disable-next-line react/jsx-no-literals -- Content allowed */}